<?php
namespace Admin\Controller;
use Think\Controller;
class MessageController extends BaseController {
    public function index(){
    	$this->verify_login();
        if(I("post.keyword")!=null){
            $data['wxname']=I("post.keyword");
        }
        $message = M('message');
        $count      = $message->where($data)->count();
        $Page       = new \Think\Page($count,10);
        $show       = $Page->show();
        $messageList = $message->where($data)->order('isread,id desc')->limit($Page->firstRow.','.$Page->listRows)->select();
        $this->assign('messageList',$messageList);
        $this->assign('page',$show);
        $this->display();
    }
    public function del(){
    	$id=I('get.id');
    	$message=M('message');
    	$res=$message->where('id='.$id)->delete();
    	if($res){
        	$this->success("删除成功",U('Contact/index'));
        }else{
        	$this->error("删除失败");
        }
    }
    public function isread(){
        $id=I('post.id');
        $message=M('message');
        $data["isread"]=1;
        $res=$message->where('id='.$id)->save($data);

        if($res){
            $this->ajaxReturn(true);
        }else{
            $this->ajaxReturn(false);
        }
    }
}